<?
include 'common/autoload.php';
$page_title = '通知详情 - ' . $GLOBALS['web_title'];
include 'common/header.html';
include 'common/left.html';
use pft\Prod\Ticket;
use \pft\notice;
use \pft\Prod\Product;
$notice = new notice();

$did = $_SESSION['memberID'];

$id = abs($_GET['id']);
if($_GET['s']) {
    $row = $notice->GetNoticeOne($id, $did);
}
else {
    $row = $notice->ReadNotice($id, $did);
}
if(!$row['id']) {
    echo '<script>alert("数据不存在!");history.go(-1);</script>';
    exit;
}
$lnkprodsHtml = '';
if($row['lnkprods']) {
    $ticket = new Ticket($GLOBALS['le']);
    $prod = new Product($GLOBALS['le']);
    $lnkprods = $prod->GetLnkProds($row['lnkprods']);
    if(is_array($lnkprods)) {
        $lnkids = array_keys($lnkprods);
        $output =  $ticket->GetTicketByLimit($lnkids, $did, -1,0, \SoapInit::GetSoapInside());
        $ticketList = '';
        $html_tpl = <<<HTML
        <div class="ui-table-container mt10">
            <table class="ui-table ui-table-inbox">
                <thead>
                    <tr>
                    <th colspan="3">牵涉到的产品</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td>产品标题</td>
                    <td>产品状态</td>
                    <td>价格</td>
                </tr>
                {ticketList}</tbody>
            </table>
        </div>
HTML;
        foreach($output as $tic) {
            $status = $tic['status']==1? '已下架' : '在售';
            $ticketList .= <<<HTML
            <tr>
                <td><a href="pi.html?{$tic['landid']}">{$lnkprods[$tic['landid']]}{$tic['ticketTitle']}</a></td>
                <td>{$status}</td>
                <td>
                    <span class="L">门市价：{$tic['marketPrice']}</span>
                    <span class="R">优惠价：{$tic['salePrice']}</span>
                </td>
            </tr>
HTML;
        }
        $lnkprodsHtml = str_replace('{ticketList}', $ticketList, $html_tpl);
    }
}
if ($row['adminid']) {
    $sqlDname = "SELECT dname FROM pft_member WHERE id={$row['adminid']} LIMIT 1";
    $GLOBALS['le']->query($sqlDname);
    $GLOBALS['le']->fetch_assoc();
    $PublishName = $GLOBALS['le']->f('dname');
}

?>
    <link media="all" rel="stylesheet" href="css/aliceui.min.css"/>
    <link media="all" rel="stylesheet" href="css/resetui.css"/>
    <style type="text/css">
		.zy_r_content{ float:left; width:740px; border:1px solid #f2f2f2; background:#fcfcfc}
		.zy_r_content .zy_msg_wrap{ min-height:817px; padding:50px; padding-top:40px; border:1px solid #fff;}
		.zy_msg_wrap .title{ font-family:"Microsoft YaHei",tahoma,arial,宋体; font-size:20px; text-align:center; font-weight:bold; color:#266b94}
		.zy_msg_wrap .descW{ width:100%; overflow:hidden; margin-top:10px; color:#959595}
		.zy_msg_wrap .descW .time{ float:left; *display:inline;}
		.zy_msg_wrap .descW .user{ float:right; *display:inline;}
		.zy_msg_wrap .descW .i{ position:relative; top:3px; display:inline-block; width:12px; height:12px; margin-right:3px; font-size:0; text-indent:-9999px; background:url(../images/other/zy_notice_desc_icon.gif) no-repeat 0 0;
			*display:inline; *float:left; *top:5px;
		}
		.zy_msg_wrap .descW .txt{ *float:left;}
        .zy_msg_wrap .descW .i.t{ background-position:left top}
        .zy_msg_wrap .descW .i.u{ background-position:left bottom;}
		.zy_msg_wrap .line{ width:100%; margin:6px 0 15px 0; border-top:1px solid #dedede; border-bottom:1px solid #fff; height:0; line-height:0; font-size:0;}
		.zy_msg_wrap .msg-content{  text-indent:2em; line-height:1.7;}
		.msg-content p img{width:500px;}
		
		
		
		
		.msg-wrap{
            position: relative;
            border:1px solid #c4ecfe;
            background-color: #f2f8fc;
            padding:20px;
            color:#808080;
            text-align: center;
        }
        .msg-wrap .title{
            font-weight: bold;
            font-size: 20px;
            color:#000;
			font-family: "Microsoft YaHei" ! important;
        }
        .msg-wrap .close {
            position: absolute;
            top: 4px;
            right: 10px;
        }
        .msg-wrap .time{
            border-bottom: 1px dashed #ccc;
            padding-bottom: 4px;
            margin-bottom: 4px;
        }
        .L{
            float: left;
            width: 120px;
        }
		
    </style>
    <!--当前位置-->
    <div class="zy_r_content" style="">
        <div class="zy_msg_wrap">
            <h3 class="title"><?=$row['title']?></h3>
            <p class="descW">
                <span class="time"><i class="i t"></i><span class="txt">发布时间：<?=$row['btime']?></span></span>
                <span class="user"><i class="i u"></i><span class="txt"><?=isset($PublishName) ? '发布商家：'. $PublishName : ''?></span></span>
            </p>
			<div class="line"></div>
            <div class="msg-content"><?=htmlspecialchars_decode(nl2br($row['content']));?></div>
            <!-- <a class="close" href="javascript:window.close();" class="ui-box-head-more">关闭</a> -->
        </div>
        <?=$lnkprodsHtml?>
    </div>
<?include("common/footer.html")?>